﻿using System;

namespace NetTopologySuite.Utilities
{
	public class PriorityQueue<T> where T : IComparable<T>
	{
		public void Add(T x)
		{
			PriorityQueueNode<T, T> node = new PriorityQueueNode<T, T>(x);
			this.queue.Enqueue(node, x);
		}

		public bool IsEmpty()
		{
			return this.queue.Count == 0;
		}

		public int Size
		{
			get
			{
				return this.queue.Count;
			}
		}

		public void Clear()
		{
			this.queue.Clear();
		}

		public T Poll()
		{
			PriorityQueueNode<T, T> priorityQueueNode = this.queue.Dequeue();
			if (priorityQueueNode != null)
			{
				return priorityQueueNode.Data;
			}
			return default(T);
		}

		private readonly AlternativePriorityQueue<T, T> queue = new AlternativePriorityQueue<T, T>();
	}
}
